package test.test;

import org.junit.Test;

/**
 * todo:一道dp题,还得思考
 * https://leetcode.cn/contest/weekly-contest-397/problems/taking-maximum-energy-from-the-mystic-dungeon/
 * @author Hasee
 *
 */
public class B {
    public int maximumEnergy(int[] energy, int k) {
    	int ans=Integer.MIN_VALUE;
    	for (int i = 0; i < k; i++) {
    		int cur=0;
			for (int j =i; j < energy.length; j+=k) {
				cur=Math.max(energy[j], cur+energy[j]);
			}
			ans=Math.max(ans, cur);
		}
    	return ans;
    }
    @Test
    public void test() {
    	int[] arr= {-2,-3,-1};
    	int ans=maximumEnergy(arr, 2);
    	System.out.println(ans);
    }
}
